package com.rabbit.eap.framework.core.xss;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.apache.commons.text.StringEscapeUtils;

import java.io.IOException;

/**
 * @projectName eap
 * @packageName com.rabbit.eap.framework.core.xss
 * @className XssJacksonSerializer
 * @author： rabbit
 * @version： 1.0
 * @since： 2020/4/26 22:19
 * <p>Description: XssJacksonSerializer </p>

 */
public class XssJacksonSerializer extends JsonSerializer<String> {

    @Override
    public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        jsonGenerator.writeString(StringEscapeUtils.escapeHtml4(s));
    }
}
